package com.xplay.xpocker.room.message;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 统一消息处理器
 */

public abstract class AbstractMessageStrategy {

    public static final String USER_SOURCE_KEY = "source";

    protected abstract int strategyName();

    @PostConstruct
    public void registerFactory() {
        messageHandler.put(strategyName(), this);
    }

    public static final ConcurrentHashMap<Integer, AbstractMessageStrategy> messageHandler = new ConcurrentHashMap<>();

    public abstract void doMessage(String code, MessageContent<Object> data);

}
